package com.wm.blog.admin.controller;

import cn.hutool.core.lang.Pair;
import com.wm.blog.center.common.utils.R;
import com.wm.blog.center.common.utils.login.StpAdminUtil;
import com.wm.blog.center.service.MemberService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: weiming
 * @Date: 2021/5/27 10:37
 * @Description:
 */
@RestController
public class MemberController {

    @Autowired
    MemberService memberService;

    @ApiOperation("管理员登录")
    @PostMapping("/admin/login")
    public R adminLogin(String username, String password) {

        Pair<Boolean, String> login =  memberService.adminLogin(username, password);

        if (login.getKey()){
            return R.ok().put("token", login.getValue());
        }
        return R.error(login.getValue());
    }

}
